﻿using HSGD.Common;
using HSGD.Services;
using Microsoft.Extensions.DependencyInjection;
using Minio;

namespace HSGD.Extensions.ServiceExtensions {
    public static class MinIOSetup {
        public static void AddMinIOSetup(this IServiceCollection services) {
            if (services == null) throw new ArgumentNullException(nameof(services));

            var Endpoint = AppSettings.app(["MinIO", "Endpoint"]);
            var AccessKey = AppSettings.app(["MinIO", "AccessKey"]);
            var SecretKey = AppSettings.app(["MinIO", "SecretKey"]);

            services.AddSingleton<IMinioClient>(new MinioClient()
                .WithEndpoint(Endpoint)
                .WithCredentials(AccessKey, SecretKey)
                .Build());

            services.AddScoped<MinioFileService>();
        }
    }
    
}
